<?php
/**
 * @Author: liuhongbin
 * @Email: 514660094@qq.com
 * @Date: 2019-02-12 16:15:10
 * @Description:
 * @LastEditors: liuhongbin
 * @LastEditTime: xxx
 */

namespace app\controller\adminapi\cloud;

use app\common\controller\AdminController;
use app\common\model\platform\Platform;
use app\common\model\system\Config;

// 外部请求当前系统同步数据
class Local extends AdminController
{
    public $notLogin = ['*'];
    public $notCheck = ['*'];

    public function initialize()
    {
        parent::initialize();
        $cloud = Config::get("cloud");
        $site_id = input('site_id', 0);
        $site_token = input('site_token', '');
        if ($site_id != $cloud['site_id'] || $site_token != $cloud['token']) {
            $this->error('站点信息或者接入秘钥错误')->send();
        }
    }

    public function getPlatformMsg()
    {
        $plaid = input('plaid', 0);
        // 屏蔽平台敏感信息
        $res = (new Platform())->where(['plaid' => $plaid])->hidden(['corp_id', 'config'])->find();
        if (!$res) {
            return $this->error('平台不存在');
        }
        return $this->success('获取成功', $res);
    }

}
